<head>
    <title><g:message code='spring.security.ui.login.title'/></title>
    <meta name='layout' content='main'/>
    <r:use module="security"/>
</head>

<body>

<form action='${postUrl}' method='POST' id="loginForm" name="loginForm" autocomplete='off'>
    <div class="sign-in login">

        <h1><g:message code='spring.security.ui.login.signin'/></h1>

        <ul class="login-form">
            <li><label for="username"><g:message code='spring.security.ui.login.username'/></li>
            <li><input type="text" name="j_username" id="username" placeholder='username'/></li>

            <li><label for="password"><g:message code='spring.security.ui.login.password'/></li>
            <li><input type="password" name="j_password" id="password" placeholder='password'/></li>
            <li class="remember-me"><label for='remember_me'><g:message
                    code='spring.security.ui.login.rememberme'/></label><input type="checkbox" class="checkbox"
                                                                               name="${rememberMeParameter}"
                                                                               id="remember_me"
                                                                               checked="checked"/> <g:link
                    controller="login" action="auth" class="login-link">Log In</g:link></li>

            <li><label for='terms_and_conditions'>Logging into compRXinsight you agree to our <g:link controller="home"
                                                                                                      action="register"
                                                                                                      class="terms-link">Terms Of Use</g:link></label>
                <input type="checkbox" class="checkbox"
                       name=""
                       id="terms_and_conditions"/></li>
        </ul>
        <ul class="register">
            <li class="link"><g:link controller="home" action="register" class="register-link">Register</g:link></li>
            <li class="password"><g:link class="forgot-password" controller='register'
                                         action='forgotPassword'><g:message
                        code='spring.security.ui.login.forgotPassword'/></g:link></li>
        </ul>
    </div>

</form>

<g:if test="${flash.message || flash.error}">
    <r:script>
        $(document).ready(function() {
            alert("Incorrect username/password");
        });


    </r:script>
</g:if>

<r:script>
    $(document).ready(function() {
        $('#username').focus();
    });
    $('.login-link').bind('click', function() {
        if ($('#terms_and_conditions').is(':checked') == false) {
            alert("You have not checked the box to say you have\nread and agree with the Terms of Use");
            return false;
        }

        $('#loginForm').submit();
        return false;
    });
    $('#password').bind('keypress', function(e) {
        var code = e.which
        if (code == $.ui.keyCode.ENTER) { //Enter keycode
            if ($('#terms_and_conditions').is(':checked') == false) {
                alert("You have not checked the box to say you have\nread and agree with the Terms of Use");
                return false;
            }
            $('#loginForm').submit();
            return false;
        }
    });

</r:script>
</body>
